package com.xiaohao.student_course.controller;

import com.xiaohao.student_course.bean.Classes;
import com.xiaohao.student_course.service.ClassesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @author 小浩
 * @date 2018-12-16 18:32
 * @package com.xiaohao.student_course.controller
 * @description
 */
@Controller
@RequestMapping("/classes")
public class ClassesController {
    @Autowired
    private ClassesService classesService;

    @RequestMapping("/query_classes_marjorname")
    @ResponseBody
    public List<Classes> getClassesByMajor(String majorname){
        return classesService.getClassesByMajor(majorname);
    }




    @RequestMapping("/query")
    public String getAllClasses(Model model){
        model.addAttribute("classesQueryPage",classesService.getAllClasses());
        return "classes-query";
    }

}
